<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head th:replace="~{common::header('未下达的采购计划一览表')}"></head>
<body>
<div class="container-fluid">
    <div class="row clearfix">
        <div class="col-md-12 column" style="text-align: center">
            <h3>
                未下达的采购计划一览表
            </h3>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <hr>
        </div>
    </div>


    <div class="row clearfix" style="max-height: 50%;overflow-y: auto;overflow-x: hidden">
        <div class="row clearfix">
            <div class="col-md-12 column">
                <div class="col-md-12 column" style="overflow: hidden">
                    <table id="dg" class="easyui-datagrid"
                           data-options="
								  	pageSize:'10',
								  	pageList:[10,20,30,40],
									pagination:true,
									rownumbers:true,
									url:'/stock/selectStockByStatus',
									method:'post',
									width:'100%'">
                        <thead>
                        <tr>
                            <th data-options="field:'ck',checkbox: true"></th>
                            <th data-options="field:'ID'" hidden>Item ID(15%)</th>
                            <th data-options="field:'STOCK_NUM',width:'19%'">Item ID(15%)</th>
                            <th data-options="field:'STOCK_NAME',width:'19%'">Item ID(15%)</th>
                            <th data-options="field:'STOCK_TYPE',width:'19%',formatter: function(value,row,index){
                                                                                    if(value=='C000-1'){
                                                                                        return '制造中心采购-公开求购';
                                                                                    }else{
                                                                                        return '制造中心采购-定向询价';
                                                                                    }} ">Product(15%)</th>
                            <th data-options="field:'status',width:'19%',formatter: function(value,row,index){
                                                                                    if(value=='C001-30'){
                                                                                        return '未确定';
                                                                                    }else if(value=='C001-40'){
                                                                                        return '待审';
                                                                                    }else if(value=='C001-50'){
                                                                                        return '未下达';
                                                                                    }else if(value=='C001-51'){
                                                                                        return '不通过';
                                                                                    }else if(value=='C001-60'){
                                                                                        return '下达';
                                                                                    }}">Product(15%)</th>
                            <th data-options="field:'submit_date',width:'19%'">Product(15%)</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>


    <div class="row clearfix">
        <div class="col-md-12 column">
            <hr>
        </div>
    </div>

    <div class="col-md-12 column">
        <div class="col-md-12 column" style="padding-top:10px;text-align:center">
            <button type="button" onclick="btn1()"  class="btn btn-primary" >下达</button>
            <button type="button" onclick="btn2()"  class="btn btn-primary" >详情</button>
        </div>
    </div>

    <script>
        var btn1=function(){
            var rows= $("#dg").datagrid("getSelections");
            if (rows.length!=0){
                for (var i = 0; i < rows.length; i++) {
                    $.ajax({
                        url: "/idMapping/updatebyStatusByStock2?StockId="+rows[i].ID,
                        method: "get",
                        success:function (){
                            $('#dg').datagrid('reload');
                        }
                    });
                }
            }
        }

        var btn2=function(){
            var rows= $("#dg").datagrid("getSelections");
            if (rows.length!=0){
                for (var i = 0; i < rows.length; i++) {
                    URL1="/stock/findbyID?ID="+rows[i].ID;
                    open(URL1,"","");
                }
            }
        }

    </script>

</div>
</body>
</html>